package com.hongsheng.util;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * TODO
 *
 * @author admin
 * @version 1.0
 * @date 2023/8/17 15:44
 */
public class GoodsSqlProvider {
    public static String getGoods(@Param("name") String name,
                                             @Param("type") String type,
                                             @Param("nature") String nature) {
        return new SQL() {{
            SELECT("*");
            FROM("tb_goods");
            if (name != null && !name.isEmpty()) {
                WHERE("name like #{name}");
            }
            if (type != null && !type.isEmpty()) {
                WHERE("type like #{type}");
            }
            if (nature!=null && !nature.isEmpty()){
                WHERE( "nature like #{nature}");
            }
        }}.toString();
    }
}
